//
//  HTMainController.swift
//  WeiBoDemo
//
//  Created by 郝涛 on 16/4/16.
//  Copyright © 2016年 郝涛. All rights reserved.
//

import UIKit

class HTMainController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        //获取tabbar
        let tabbar = HTTabBar()
        
        setValue(tabbar, forKey: "tabBar")
        tabbar.czDeletate = self
        
        //传入
        addChildViewController(HTHomeController(), ImageName: "tabbar_home", title: "首页")
        addChildViewController(HTDiscoverController(), ImageName: "tabbar_home", title: "发现")
        addChildViewController(HTMessageController(), ImageName: "tabbar_home", title: "消息")
        addChildViewController(HTProfileController(), ImageName: "tabbar_home", title: "我的")
        
    }

    //添加控制器 图片名字 和 title
    func addChildViewController(childController: UIViewController, ImageName:String , title:String ) {
        //设置图标
        childController.tabBarItem.image = UIImage(named: ImageName)
        //设置高亮的图片
        childController.tabBarItem.selectedImage = UIImage(named: "\(ImageName)_selected")
        //设置名字
        childController.title = title
        
        //添加控制器
        addChildViewController(UINavigationController(rootViewController: childController))
    }
    
}
extension HTMainController: CZTabBarDelegate{
    func composeButtonClick() {
        print("撰写按钮被点击啦")
        presentViewController(UINavigationController(rootViewController: HTComponseViewController()), animated: true, completion: nil)
    }
}